package com.unohacha.qqj.fzdr.personal.view.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.unohacha.qqj.fzdr.R;
import com.unohacha.qqj.fzdr.personal.bean.UserInfoBean;
import com.unohacha.qqj.fzdr.imp.MyApplication;
import com.unohacha.qqj.fzdr.personal.presenter.IPersonalPresenter;
import com.unohacha.qqj.fzdr.personal.presenter.PersonalPresenter;
import com.unohacha.qqj.fzdr.personal.view.IPersonal;
import com.unohacha.qqj.fzdr.util.Prefer;
import com.unohacha.qqj.mylibrary.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 设置
 */
public class SettingActivity extends BaseActivity implements IPersonal {

    @BindView(R.id.common_back)
    ImageView commonBack;
    @BindView(R.id.common_title)
    TextView commonTitle;
    @BindView(R.id.common_right_image)
    ImageView commonRightImage;
    @BindView(R.id.common_right_text)
    TextView commonRightText;

    @BindView(R.id.sf_account_tv)
    TextView sfAccountTv;
    @BindView(R.id.phone_tv)
    TextView phoneTv;
    @BindView(R.id.pwd_tv)
    TextView pwdTv;
    @BindView(R.id.about_tv)
    TextView aboutTv;
    @BindView(R.id.clear_hc_tv)
    TextView clearHcTv;
    @BindView(R.id.login_out)
    TextView loginOut;

    @OnClick(R.id.rl_password)
    void onPasswordClick() {
        jumpToOtherActivity(this, ModifyPasswordActivity.class);
    }


    IPersonalPresenter iPersonalPresenter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initView() {
        super.initView();
        commonRightImage.setVisibility(View.GONE);
        commonRightText.setVisibility(View.GONE);
        commonTitle.setText(getResources().getString(R.string.title_setting));

        iPersonalPresenter = new PersonalPresenter(this);
        iPersonalPresenter.getUserInfo(Prefer.getInstance().getToken());
    }

    // 点击修改 绑定手机号
    @OnClick(R.id.rl_phone)
    void onPhoneClick() {
        jumpToOtherActivity(this, ConfirmPhoneActivity.class);
    }


    @OnClick(R.id.login_out)
    void setLoginOut() {
        loginOutFunc();
    }

    //退出登录
    private void loginOutFunc() {
        MyApplication.getInstance().gotoLoginActivity();
        finish();
    }

    @OnClick(R.id.common_back)
    public void setCommonBack() {
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void showUserInfo(UserInfoBean userInfoBean) {
        sfAccountTv.setText(userInfoBean.getMember_id()); // 账号
        phoneTv.setText(userInfoBean.getTelephone());// 手机号
    }
}
